Files
tsgo/testdata/tests/cases/compiler/packageJsonImportsWildcardTsExtensionError.ts
a311dd9b63 Fix module resolver bug exposed by malformed package.json import patterns (#2680)
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: andrewbranch <[email protected]>
Co-authored-by: Andrew Branch <[email protected]>
2026-02-09 21:53:00 +00:00

39 lines
939 B
TypeScript

// @noEmit: true
// @noTypesAndSymbols: true
// @module: nodenext
// @moduleResolution: nodenext
// Test verifies that when a module specifier contains ".ts" that gets matched by a
// wildcard pattern, resolvedUsingTsExtension is correctly set to true.
// Example: import "#/foo.ts.omg" with pattern "#/*.omg": "./src/*"
// The * matches "foo.ts", and when expanded becomes "./src/foo.ts"
// Since the wildcard matched ".ts" from the specifier, an error should be reported.
// @filename: src/foo.ts
export function hello() {
return "world";
}
// @filename: src/index.ts
import { hello } from "#/foo.ts.omg";
hello();
// @filename: package.json
{
"type": "module",
"imports": {
"#/*.omg": "./src/*"
}
}
// @filename: tsconfig.json
{
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "nodenext",
"rootDir": "src",
"outDir": "dist"
},
"include": ["src"]
}