File tree Expand file tree Collapse file tree 4 files changed +39
-3
lines changed Expand file tree Collapse file tree 4 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -2744,11 +2744,11 @@ namespace ts {
2744
2744
const node = getParseTreeNode ( contextNode ) ;
2745
2745
const isSimilarNode = node && node . kind === contextNode . kind ;
2746
2746
const startPos = pos ;
2747
- if ( isSimilarNode ) {
2748
- pos = skipTrivia ( currentSourceFile ! . text , pos ) ;
2747
+ if ( isSimilarNode && currentSourceFile ) {
2748
+ pos = skipTrivia ( currentSourceFile . text , pos ) ;
2749
2749
}
2750
2750
if ( emitLeadingCommentsOfPosition && isSimilarNode && contextNode . pos !== startPos ) {
2751
- const needsIndent = indentLeading && ! positionsAreOnSameLine ( startPos , pos , currentSourceFile ! ) ;
2751
+ const needsIndent = indentLeading && currentSourceFile && ! positionsAreOnSameLine ( startPos , pos , currentSourceFile ) ;
2752
2752
if ( needsIndent ) {
2753
2753
increaseIndent ( ) ;
2754
2754
}
Original file line number Diff line number Diff line change
1
+ tests/cases/compiler/crashInEmitTokenWithComment.ts(5,4): error TS2345: Argument of type '({ [foo.bar]: c }: {}) => any' is not assignable to parameter of type 'string'.
2
+ tests/cases/compiler/crashInEmitTokenWithComment.ts(5,7): error TS2537: Type '{}' has no matching index signature for type 'string'.
3
+
4
+
5
+ ==== tests/cases/compiler/crashInEmitTokenWithComment.ts (2 errors) ====
6
+ // GH#32358
7
+ const fn = (param: string) => undefined;
8
+
9
+ const foo = {bar: 'a'};
10
+ fn(({[foo.bar]: c}) => undefined);
11
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12
+ !!! error TS2345: Argument of type '({ [foo.bar]: c }: {}) => any' is not assignable to parameter of type 'string'.
13
+ ~~~~~~~
14
+ !!! error TS2537: Type '{}' has no matching index signature for type 'string'.
Original file line number Diff line number Diff line change
1
+ //// [crashInEmitTokenWithComment.ts]
2
+ // GH#32358
3
+ const fn = ( param : string ) => undefined ;
4
+
5
+ const foo = { bar : 'a' } ;
6
+ fn ( ( { [ foo . bar ] : c } ) => undefined ) ;
7
+
8
+ //// [crashInEmitTokenWithComment.js]
9
+ // GH#32358
10
+ var fn = function ( param ) { return undefined ; } ;
11
+ var foo = { bar : 'a' } ;
12
+ fn ( function ( _a ) {
13
+ var _b = foo . bar , c = _a [ _b ] ;
14
+ return undefined ;
15
+ } ) ;
Original file line number Diff line number Diff line change
1
+ // @noTypesAndSymbols : true
2
+
3
+ // GH#32358
4
+ const fn = ( param : string ) => undefined ;
5
+
6
+ const foo = { bar : 'a' } ;
7
+ fn ( ( { [ foo . bar ] : c } ) => undefined ) ;
You can’t perform that action at this time.
0 commit comments