Download presentation
Presentation is loading. Please wait.
Published byEstella Bennett Modified over 9 years ago
10
patterns TypeScript size
14
interface IModelChangeAccessor { insertText(position:IPosition, text:string): IEditorPosition; deleteText(range:IRange): IDeleteTextResult; } interface IEditableTextModel { change(callback: (changeAccessor:IModelChangeAccessor)=>any): … } Interfaces to be implemented
15
export interface IValidationFilter { (resource:IEventEmitter): boolean; } public constructor(filter:IValidationFilter) { } new Validator((resource)=>this.includeModel(resource)); Callbacks
16
interface ICommonEditorOptions { selectOnLineNumbers?:boolean; glyphMargin?:boolean; roundedSelection?:boolean; theme?:string; readOnly?:boolean; //… } Option bags
17
var options:IBuildData = JSON.parse(req.responseText); export interface IBuildData { requestId:string; logOutput?:string; buildOutput?:BuildOutput; killOutput?:KillOutput; } JSON structures
18
declare module WinJS { module Binding { //... } class Promise { //... } External types from other libraries
19
http://promises-aplus.github.io/promises-spec/ https://github.com/promises-aplus/promises-spec/blob/master/implementations.md promise.then((result) => {...}, (err) => {...});
20
class Promise { then (success?: (value: T) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise ; //… } export interface ITypeDeclarationSupport { findTypeDeclaration(position:Editor.IPosition):Promise ; }
21
TSD: a package manager to search and install TypeScript definition files directly from the DefinitelyTyped repository.TypeScript DefinitelyTyped TSD: a package manager to search and install TypeScript definition files directly from the DefinitelyTyped repository.TypeScript DefinitelyTyped
22
We started with internal modules
23
patterns TypeScript size
26
“… our dependency graph was such a mess that each area had a dependency on just about every other area.”
28
File main.ts: import adder= require("./adder"); adder.add(3,4); File adder.ts: export function add(op1: number, op2: number):number { return op1+op2; }
29
var adder = require(“adder”); adder.add() tsc --module amd main.ts tsc --module commonjs main.ts
30
AMD in JavaScript define([‘…./winjs.base‘, ‘…./zoneWidget’], function(WinJS, ZoneWidget) { … } ); AMD in TypeScript import WinJS= require('vs/base/lib/winjs'); import ZoneWidget = require('vs/editor/zoneWidget');
33
csharp.ts export class CSMode extends AbstractMode { constructor() { super('vs.languages.csharp'); } // lots of code …. } csharp.contribution.ts modeRegistry.registerMode( [‘text/x-csharp'], new Platform.Descriptor( 'vs/languages/csharp/csharp', ‘CSMode') ); Registered on start-up Loaded on demand
35
patterns TypeScript size
36
“As I did conversions, I began typing various object literals I was passing around as interfaces. Soon enough, I realized how inconsistent I was, the same data was flowing around in at least 3 different formats. This is because of the easiness through which you can create literals in JavaScript …. Need some placeholder for data?... Just create a new literal object.”
37
tsc –declarations –out typescriptservices.js typescript.ts
41
for MSDN Ultimate subscribers Go to http://msdn.Microsoft.com/specialoffershttp://msdn.Microsoft.com/specialoffers SPECIAL OFFERS Partner Program
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.