Merge pull request #5827 from Microsoft/shebangBeforeReferences
ignore all trivia except singleline comments when processing triplesl…
This commit is contained in:
commit
090eb205b2
5 changed files with 89 additions and 4 deletions
|
@ -5428,11 +5428,13 @@ namespace ts {
|
|||
// reference comment.
|
||||
while (true) {
|
||||
const kind = triviaScanner.scan();
|
||||
if (kind === SyntaxKind.WhitespaceTrivia || kind === SyntaxKind.NewLineTrivia || kind === SyntaxKind.MultiLineCommentTrivia) {
|
||||
continue;
|
||||
}
|
||||
if (kind !== SyntaxKind.SingleLineCommentTrivia) {
|
||||
break;
|
||||
if (isTrivia(kind)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() };
|
||||
|
|
21
tests/baselines/reference/shebangBeforeReferences.js
Normal file
21
tests/baselines/reference/shebangBeforeReferences.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
//// [tests/cases/compiler/shebangBeforeReferences.ts] ////
|
||||
|
||||
//// [f.d.ts]
|
||||
|
||||
declare module "test" {
|
||||
let x: number;
|
||||
}
|
||||
|
||||
//// [f.ts]
|
||||
#!/usr/bin/env node
|
||||
|
||||
/// <reference path="f.d.ts"/>
|
||||
|
||||
declare function use(f: number): void;
|
||||
import {x} from "test";
|
||||
use(x);
|
||||
|
||||
//// [f.js]
|
||||
#!/usr/bin/env node"use strict";
|
||||
var test_1 = require("test");
|
||||
use(test_1.x);
|
23
tests/baselines/reference/shebangBeforeReferences.symbols
Normal file
23
tests/baselines/reference/shebangBeforeReferences.symbols
Normal file
|
@ -0,0 +1,23 @@
|
|||
=== tests/cases/compiler/f.ts ===
|
||||
#!/usr/bin/env node
|
||||
|
||||
/// <reference path="f.d.ts"/>
|
||||
|
||||
declare function use(f: number): void;
|
||||
>use : Symbol(use, Decl(f.ts, 0, 0))
|
||||
>f : Symbol(f, Decl(f.ts, 4, 21))
|
||||
|
||||
import {x} from "test";
|
||||
>x : Symbol(x, Decl(f.ts, 5, 8))
|
||||
|
||||
use(x);
|
||||
>use : Symbol(use, Decl(f.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(f.ts, 5, 8))
|
||||
|
||||
=== tests/cases/compiler/f.d.ts ===
|
||||
|
||||
declare module "test" {
|
||||
let x: number;
|
||||
>x : Symbol(x, Decl(f.d.ts, 2, 7))
|
||||
}
|
||||
|
24
tests/baselines/reference/shebangBeforeReferences.types
Normal file
24
tests/baselines/reference/shebangBeforeReferences.types
Normal file
|
@ -0,0 +1,24 @@
|
|||
=== tests/cases/compiler/f.ts ===
|
||||
#!/usr/bin/env node
|
||||
|
||||
/// <reference path="f.d.ts"/>
|
||||
|
||||
declare function use(f: number): void;
|
||||
>use : (f: number) => void
|
||||
>f : number
|
||||
|
||||
import {x} from "test";
|
||||
>x : number
|
||||
|
||||
use(x);
|
||||
>use(x) : void
|
||||
>use : (f: number) => void
|
||||
>x : number
|
||||
|
||||
=== tests/cases/compiler/f.d.ts ===
|
||||
|
||||
declare module "test" {
|
||||
let x: number;
|
||||
>x : number
|
||||
}
|
||||
|
15
tests/cases/compiler/shebangBeforeReferences.ts
Normal file
15
tests/cases/compiler/shebangBeforeReferences.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
// @module: commonjs
|
||||
|
||||
// @filename: f.d.ts
|
||||
declare module "test" {
|
||||
let x: number;
|
||||
}
|
||||
|
||||
// @filename: f.ts
|
||||
#!/usr/bin/env node
|
||||
|
||||
/// <reference path="f.d.ts"/>
|
||||
|
||||
declare function use(f: number): void;
|
||||
import {x} from "test";
|
||||
use(x);
|
Loading…
Reference in a new issue