diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 027007fb15b62..eb5024edfad45 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3881,7 +3881,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - errorNoModuleMemberSymbol(moduleSymbol, targetSymbol, node, name); + errorNoModuleMemberSymbol(moduleSymbol, targetSymbol, getSourceFileOfNode(node), name); } return symbol; } @@ -5919,7 +5919,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function symbolToStringWorker(writer: EmitTextWriter) { const entity = builder(symbol, meaning!, enclosingDeclaration, nodeFlags)!; // TODO: GH#18217 - // add neverAsciiEscape for GH#39027 const printer = enclosingDeclaration?.kind === SyntaxKind.SourceFile ? createPrinterWithRemoveCommentsNeverAsciiEscape() : createPrinterWithRemoveComments(); diff --git a/tests/baselines/reference/unicodeInModuleSpecifierError1.errors.txt b/tests/baselines/reference/unicodeInModuleSpecifierError1.errors.txt new file mode 100644 index 0000000000000..5e4cf21ed7984 --- /dev/null +++ b/tests/baselines/reference/unicodeInModuleSpecifierError1.errors.txt @@ -0,0 +1,24 @@ +main.ts(1,10): error TS2305: Module '"./🦁.ts"' has no exported member 'bar'. +main.ts(1,15): error TS2459: Module '"./🦁.ts"' declares 'baz' locally, but it is not exported. +main.ts(2,10): error TS2305: Module '"./🦁.ts"' has no exported member 'bar'. +main.ts(2,15): error TS2459: Module '"./🦁.ts"' declares 'baz' locally, but it is not exported. + + +==== 🦁.ts (0 errors) ==== + export const foo = "bar"; + const baz = "baz"; + +==== main.ts (4 errors) ==== + import { bar, baz } from './🦁.ts'; + ~~~ +!!! error TS2305: Module '"./🦁.ts"' has no exported member 'bar'. + ~~~ +!!! error TS2459: Module '"./🦁.ts"' declares 'baz' locally, but it is not exported. +!!! related TS2728 🦁.ts:2:7: 'baz' is declared here. + export { bar, baz } from './🦁.ts'; + ~~~ +!!! error TS2305: Module '"./🦁.ts"' has no exported member 'bar'. + ~~~ +!!! error TS2459: Module '"./🦁.ts"' declares 'baz' locally, but it is not exported. +!!! related TS2728 🦁.ts:2:7: 'baz' is declared here. + \ No newline at end of file diff --git a/tests/baselines/reference/unicodeInModuleSpecifierError1.symbols b/tests/baselines/reference/unicodeInModuleSpecifierError1.symbols new file mode 100644 index 0000000000000..e58a6e777e5d0 --- /dev/null +++ b/tests/baselines/reference/unicodeInModuleSpecifierError1.symbols @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/unicodeInModuleSpecifierError1.ts] //// + +=== 🦁.ts === +export const foo = "bar"; +>foo : Symbol(foo, Decl(🦁.ts, 0, 12)) + +const baz = "baz"; +>baz : Symbol(baz, Decl(🦁.ts, 1, 5)) + +=== main.ts === +import { bar, baz } from './🦁.ts'; +>bar : Symbol(bar, Decl(main.ts, 0, 8)) +>baz : Symbol(baz, Decl(main.ts, 0, 13)) + +export { bar, baz } from './🦁.ts'; +>bar : Symbol(bar, Decl(main.ts, 1, 8)) +>baz : Symbol(baz, Decl(main.ts, 1, 13)) + diff --git a/tests/baselines/reference/unicodeInModuleSpecifierError1.types b/tests/baselines/reference/unicodeInModuleSpecifierError1.types new file mode 100644 index 0000000000000..7fd9a49f4b2a8 --- /dev/null +++ b/tests/baselines/reference/unicodeInModuleSpecifierError1.types @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/unicodeInModuleSpecifierError1.ts] //// + +=== 🦁.ts === +export const foo = "bar"; +>foo : "bar" +> : ^^^^^ +>"bar" : "bar" +> : ^^^^^ + +const baz = "baz"; +>baz : "baz" +> : ^^^^^ +>"baz" : "baz" +> : ^^^^^ + +=== main.ts === +import { bar, baz } from './🦁.ts'; +>bar : any +> : ^^^ +>baz : any +> : ^^^ + +export { bar, baz } from './🦁.ts'; +>bar : any +> : ^^^ +>baz : any +> : ^^^ + diff --git a/tests/cases/compiler/unicodeInModuleSpecifierError1.ts b/tests/cases/compiler/unicodeInModuleSpecifierError1.ts new file mode 100644 index 0000000000000..c3e928c9dd9d6 --- /dev/null +++ b/tests/cases/compiler/unicodeInModuleSpecifierError1.ts @@ -0,0 +1,11 @@ +// @module: commonjs +// @allowImportingTsExtensions: true +// @noEmit: true + +// @Filename: 🦁.ts +export const foo = "bar"; +const baz = "baz"; + +// @Filename: main.ts +import { bar, baz } from './🦁.ts'; +export { bar, baz } from './🦁.ts';