Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: lib/base.ts

Issue 2434903002: Fix crash generating facades for loasd. Fix bug in how we handle TypePredicates. Add test for TypeP… (Closed)
Patch Set: Fix crash generating facades for loasd. Fix bug in how we handle TypePredicates. Add test for TypeP… Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/declaration.ts » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import * as dartStyle from 'dart-style'; 1 import * as dartStyle from 'dart-style';
2 import * as path from 'path'; 2 import * as path from 'path';
3 import * as ts from 'typescript'; 3 import * as ts from 'typescript';
4 4
5 import {OutputContext, Transpiler} from './main'; 5 import {OutputContext, Transpiler} from './main';
6 6
7 /** 7 /**
8 * Map from identifier name to resolved type. 8 * Map from identifier name to resolved type.
9 * Example: 'E' should map to a TypeNode for number when resolving a usage of My Array<number> 9 * Example: 'E' should map to a TypeNode for number when resolving a usage of My Array<number>
10 * where MyArray is the alias type: 10 * where MyArray is the alias type:
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 242 }
243 } 243 }
244 244
245 export function isCallable(decl: ClassLike): boolean { 245 export function isCallable(decl: ClassLike): boolean {
246 let members = decl.members as Array<ts.ClassElement>; 246 let members = decl.members as Array<ts.ClassElement>;
247 return members.some((member) => { 247 return members.some((member) => {
248 return member.kind === ts.SyntaxKind.CallSignature; 248 return member.kind === ts.SyntaxKind.CallSignature;
249 }); 249 });
250 } 250 }
251 251
252 export function copyLocation(src: ts.TextRange, dest: ts.TextRange) { 252 export function copyLocation(src: ts.Node, dest: ts.Node) {
253 dest.pos = src.pos;
254 dest.end = src.end;
255 dest.parent = src.parent;
256 }
257
258 export function copyNodeArrayLocation(src: ts.TextRange, dest: ts.NodeArray<any> ) {
253 dest.pos = src.pos; 259 dest.pos = src.pos;
254 dest.end = src.end; 260 dest.end = src.end;
255 } 261 }
256 262
257 // Polyfill for ES6 Array.find. 263 // Polyfill for ES6 Array.find.
258 export function arrayFindPolyfill<T>( 264 export function arrayFindPolyfill<T>(
259 nodeArray: ts.NodeArray<T>, predicate: (node: T) => boolean): T { 265 nodeArray: ts.NodeArray<T>, predicate: (node: T) => boolean): T {
260 for (let i = 0; i < nodeArray.length; ++i) { 266 for (let i = 0; i < nodeArray.length; ++i) {
261 if (predicate(nodeArray[i])) return nodeArray[i]; 267 if (predicate(nodeArray[i])) return nodeArray[i];
262 } 268 }
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 if (hasValidParameters) this.emitNoSpace(','); 547 if (hasValidParameters) this.emitNoSpace(',');
542 let positionalOptional = parameters.slice(firstInitParamIdx, parameters.le ngth); 548 let positionalOptional = parameters.slice(firstInitParamIdx, parameters.le ngth);
543 this.emit('['); 549 this.emit('[');
544 this.visitParameterList(positionalOptional); 550 this.visitParameterList(positionalOptional);
545 this.emitNoSpace(']'); 551 this.emitNoSpace(']');
546 } 552 }
547 553
548 this.emitNoSpace(')'); 554 this.emitNoSpace(')');
549 } 555 }
550 } 556 }
OLDNEW
« no previous file with comments | « no previous file | lib/declaration.ts » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698