Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Candidates for possible Typescript AST transformations #17

Open
zspitz opened this issue Jan 23, 2017 · 1 comment
Open

Candidates for possible Typescript AST transformations #17

zspitz opened this issue Jan 23, 2017 · 1 comment

Comments

@zspitz
Copy link
Owner

zspitz commented Jan 23, 2017

  • Constructor syntax
    var wdApp = new Word.Application();
    
    would map to
    var wdApp = new ActiveXObject('Word.Application');
    
  • Event handlers (using https://github.com/zspitz/activex-js-events) Generate declarations for event handling #16
    wdApp.on('Quit', function(params) { ... });
    
    would map to
    ActiveXObject.on(wdApp, 'Quit', [], function(params) { ... });
    
  • Property setters with parameters, which are invalid Typescript Generate property setters with parameters #15
    var dict = new ActiveXObject('Scripting.Dictionary');
    dict.Item('a') = 'Athens';
    
    would map to a helper function:
    ActiveXObject.set(dict, 'Item', ['a'], 'Athens');`
    
  • Indexers
    var athens = dict['Athens'];
    
    would map to something like
    var athens = dict.Item('Athens');
    
    This would have to handle the difference between 0-based and 1-based collections, and also sometimes where the key is not a number or string

microsoft/TypeScript#6508

@zspitz zspitz changed the title Custom code generation Candidates for possible Typescript AST transformations Feb 22, 2017
@zspitz
Copy link
Owner Author

zspitz commented Feb 22, 2017

Simulate default properties:

var rst: DAO.Recordset;
var lastName: string = rst('LastName');

would map to

var rst: DAO.Recordset;
var lastName: string = rst.Fields('LastName').Value;

because we know the type of lastName, we can step through the default property chain (Fields, Value) until we reach a compatible property. Alternatively, the default property chain should be followed until the end, and lastName would have the type of .Value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant